//
//  CDRightCategoryView.m
//  CuriosityDaily3
//
//  Created by 安林 on 16/9/25.
//  Copyright © 2016年 theBestTeam. All rights reserved.
//

#import "CDRightCategoryView.h"
#import "CDcategoryCell.h"
#import "CDButtomCell.h"
static NSString* cagegoryCellid = @"cellcagegoryCellidid";
static NSString* buttomCellid = @"buttomCellid";


@interface CDRightCategoryView()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation CDRightCategoryView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}


- (void)awakeFromNib
{
    [self setupUI];
    
}
- (void)setupUI
{
    self.backgroundColor = [UIColor clearColor];
    UITableView *tableView = [[UITableView alloc]init];
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [tableView registerClass:[CDcategoryCell class] forCellReuseIdentifier:cagegoryCellid];
    [tableView registerClass:[CDButtomCell class] forCellReuseIdentifier:buttomCellid];
    [self addSubview:tableView];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.backgroundColor = [UIColor clearColor];
    tableView.rowHeight = 60;
    // 设置自动布局
    [tableView mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.left.right.offset(0);
        make.bottom.offset(-80);
    }];
   
    
    self.rightTableView =tableView;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 7;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row <4) {
        CDcategoryCell *cell = [tableView dequeueReusableCellWithIdentifier:cagegoryCellid forIndexPath:indexPath];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else{
        CDButtomCell *cell = [tableView dequeueReusableCellWithIdentifier:buttomCellid forIndexPath:indexPath];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}


//- (NSArray*)loadBusinessTypeData
//{
//    // 1. 加载 plist
//    NSURL* url = [[NSBundle mainBundle] URLForResource:@"ButtonType.plist" withExtension:nil];
//    NSArray* list = [NSArray arrayWithContentsOfURL:url];
//    
//    // 2. 遍历数组，字典转模型
//    NSMutableArray* arrayM = [NSMutableArray array];
//    for (NSDictionary* dict in list) {
//        [arrayM addObject:[CDButtomBtnType businessTypeWithDict:dict]];
//    }
//    
//    // 3. 返回数组
//    return arrayM.copy;
//}

@end
